<?php

namespace app\student\controller;

use app\student\model\StudentLoginModel;
use think\App;
use think\Db;

class Login extends \think\Controller
{
    //从表单接受的学生姓名和密码进行判断
    public function studentLogin()
    {
        if($this->request->isPost())
        {
            $login = $this->request->post();
            $result = StudentLoginModel::studentLogin($login);
            if(empty($result))
            {
                return $this->success('登录失败','Login/studentLogin');
            }else{
                session('s_name',$result);
                //跳转到学生查询界面
//                $this->success('新增成功', '/student/Student_Base/studentBase','',0);
                $this->redirect('/student/Student_Base/studentBase');
//                Header('Location:/student/Student_Base/studentBase');
                //
//                echo "<a href='/student/Student_Base/studentBase'>登录成功</a>";
            }
        }else{

            return $this->fetch('Login/studentLogin');
        }

    }

    public function studentOut()
    {
        session('s_name',null);
        echo "<a href='/student/Login_Teacher_Student/TeacherStudent'>退出成功</a>";
    }
}